<%= error_messages_for 'category' %>

<!--[form:category]-->
<p><label for="category_name">Name</label><br/>
<%= text_field 'category', 'name'  %></p>

<p><label for="category_parent_id">Parent Category</label><br/>
<%= collection_select :category, :parent_id, @all_categories, :id, :long_name, {}, {"style" => "width:250px"} %></p>

<%= observe_field :category_parent_id, 
                  :update => 'treatmentWrapper', 
                  :url => {:action => :tax_treatments}, 
                  :with => "'category_id=#{@category.id}&parent_id=' + encodeURIComponent(value)",
                  :on => 'changed' -%>
<%= observe_field :category_parent_id, 
                  :update => 'variationsWrapper', 
                  :url => {:controller => :variations, :action => :category_variations}, 
                  :with => "'category_id=#{@category.id}&parent_id=' + encodeURIComponent(value)", 
                  :on => 'changed' -%>                   
<div id="variationsWrapper">
  <%= render :partial => 'shared/variations', :locals => {:variations => @category.variations, :category => @category, :product => nil} -%>
</div>
<div id="treatmentWrapper">
  <%= render :partial => 'shared/tax_treatments', :locals => {:tax_treatments => @all_tax_treatments, :selected_treatments => @category.tax_treatments} -%>
</div>
<!--[eoform:category]-->

